import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
const router = new Router({
  routes: [
    { path: '/login', component: () => import('@/views/login/index'), hidden: true },
    { path: '/404', component: () => import('@/views/404'), hidden: true },

    {
      path: '/',
      component: Layout,
      redirect: '/dashboard',
      name: '导航',
      hidden: true,
      children: [{
        path: 'dashboard',
        meta:{ roles:0, title:"导航" },
        component: () => import('@/views/dashboard/index')
      }]
    },



    {
      path: '/userCharge',
      component: Layout,
      children: [
        {
          path: 'userCharge',
          name: 'userCharge',
          meta: { title: '用户管理', icon: 'password', roles: 1 },
          component: () => import('@/views/userCharge/userCharge')
        }
      ]
    },
  
    {
      path: '/workDay',
      component: Layout,
      children: [
        {
          path: 'workDay',
          name: 'workDay',
          component: () => import('@/views/workDay/workDay'),
          meta: { title: '工作日管理', icon: 'form', roles: 1 }
        }
      ]
    },
    {
      path: '/roleCharge',
      component: Layout,
      children: [
        {
          path: 'roleCharge',
          name: 'roleCharge',
          component: () => import('@/views/roleCharge/roleCharge'),
          meta: { title: '角色管理', icon: 'user', roles: 1 }
        }
      ]
    },
    {
      path: '/unusualAttendance',
      component: Layout,
      children: [
        {
          path: 'unusualAttendance',
          name: 'unusualAttendance',
          component: () => import('@/views/unusualAttendance/unusualAttendance'),
          meta: { title: '异常考勤处理', icon: 'table', roles: 3 }
        }
      ]
    },
    {
      path: '/attendanceRecord',
      component: Layout,
      children: [
        {
          path: 'attendanceRecord',
          name: 'attendanceRecord',
          component: () => import('@/views/attendanceRecord/attendanceRecord'),
          meta: { title: '员工考勤', icon: 'nested', roles: 2 }
        }
      ]
    },
    {
      path: '/dayOff',
      component: Layout,
      children: [
        {
          path: 'dayOffCheck',
          name: 'dayOffcheck',
          component:(resolve) => require(['@/views/dayOff/dayOffCheck'], resolve),
          meta: { title: '请假审批', icon: 'tree', roles: 3 }
        }
      ]
    },
    {
      path: '/dayOff',
      component: Layout,
      children: [
        {
          path: 'dayOffApplication',
          name: 'dayOffApplication',
          component: () => import('@/views/dayOff/dayOffApplication'),
          meta: { title: '请假申请', icon: 'form', roles: 4 }
        }
      ]
    },
    {
      path: '/attendanceMaintenance',
      component: Layout,
      children: [
        {
          path: 'attendanceMaintenance',
          name: 'attendanceMaintenance',
          component: () => import('@/views/attendanceMaintenance/attendanceMaintenance'),
          meta: { title: '考勤异常维护', icon: 'form', roles: 4 }
        }
      ]
    },
    {
      path: '/sign',
      component: Layout,
      children: [
        {
          path: 'sign',
          name: 'sign',
          component: () => import('@/views/sign/sign'),
          meta: { title: '签到管理', icon: 'user', roles: 4 }
        }
      ]
    },

    { path: '*', redirect: '/404', hidden: true }
  ]
})

export default router
  // form 对应的路由
  // {
  //   path: '/userCharge',
  //   component: Layout,
  //   redirect: '/userCharge/table',
  //   name: 'userCharge',
  //   meta: { title: '用户管理', icon: 'example' },
  //   children: [
  //     {
  //       path: 'table',
  //       name: 'Table',
  //       component: () => import('@/views/table/index'),
  //       meta: { title: 'Table', icon: 'table' }
  //     },
  //     {
  //       path: 'tree',
  //       name: 'Tree',
  //       component: () => import('@/views/tree/index'),
  //       meta: { title: 'Tree', icon: 'tree' }
  //     }
  //   ]
  // },

  // {
  //   path: '/nested',
  //   component: Layout,
  //   redirect: '/nested/menu1',
  //   name: 'nested',
  //   meta: {
  //     title: '角色管理',
  //     icon: 'nested'
  //   },
  //   children: [
  //     {
  //       path: 'menu1',
  //       component: () => import('@/views/nested/menu1/index'), // Parent router-view
  //       name: 'menu1',
  //       meta: { title: 'menu1' },
  //       children: [
  //         {
  //           path: 'menu1-1',
  //           component: () => import('@/views/nested/menu1/menu1-1'),
  //           name: 'menu1-1',
  //           meta: { title: 'menu1-1' }
  //         },
  //         {
  //           path: 'menu1-2',
  //           component: () => import('@/views/nested/menu1/menu1-2'),
  //           name: 'menu1-2',
  //           meta: { title: 'menu1-2' },
  //           children: [
  //             {
  //               path: 'menu1-2-1',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
  //               name: 'menu1-2-1',
  //               meta: { title: 'menu1-2-1' }
  //             },
  //             {
  //               path: 'menu1-2-2',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
  //               name: 'menu1-2-2',
  //               meta: { title: 'menu1-2-2' }
  //             }
  //           ]
  //         },
  //         {
  //           path: 'menu1-3',
  //           component: () => import('@/views/nested/menu1/menu1-3'),
  //           name: 'menu1-3',
  //           meta: { title: 'menu1-3' }
  //         }
  //       ]
  //     },
  //     {
  //       path: 'menu2',
  //       component: () => import('@/views/nested/menu2/index'),
  //       meta: { title: 'menu2' }
  //     }
  //   ]
  // },
  // 测试路由

  // { path: '*', redirect: '/404', hidden: true }
// ]

// export default new Router({
//   // mode: 'history', //后端支持可开
//   scrollBehavior: () => ({ y: 0 }),
//   routes: constantRouterMap
// })

// export const dynamicRouter = [
  
// ]

// { path: '*', redirect: '/404', hidden: true }
